{extend name=".././view/create.html" /}
{block name="jscss"}
<style>
	.dh {
      min-height:50px;
      size:24px;
      padding-top:10px;
      text-align:center;
      min-height: 30px;
      float: left;
      margin-right: 1px;
    }
    .wancheng {
      border-bottom: 3px solid #01AAED;
    }

    .jinxing {
      border-bottom: 3px solid #FF5722;
    }

    .weicaozuo {
      border-bottom: 3px solid #FFB800;
    }
  </style>
{/block}
{block name="form"}
<div class="layui-form-item">
	<div class="dh wancheng" style="width: 10%;">开始</div>
	<div class="dh wancheng" style="width: 20%;">考试信息</div>
	<div class="dh wancheng" style="width: 20%;">各年级参加考试学科和分数线</div>
	<div class="dh wancheng" style="width: 20%;">生成参加考试学生名单</div>
	<div class="dh jinxing" style="width: 20%;">分配录入成绩任务</div>
	<div class="dh weicaozuo" style="width: 9%;">完成</div>
</div>
<form class="layui-form layui-form-pane" lay-filter="myform">
	<input id="kaoshi_id" name="kaoshi_id" value="{$list.set.kaoshi_id}" type="hidden">
	<div class="layui-form-item">
		<label for="teacher_name" class="layui-form-label">
			<span class="x-red">*</span>教师姓名
		</label>
		<div class="layui-input-block" id="admin_id" school_id="">
		</div>
	</div>
	<div class="layui-form-item">
		<label for="school_id" class="layui-form-label"><span class="x-red">*</span>学校</label>
		<div class="layui-input-block">
			<select name="school_id" id="school_id" lay-verify="required" lay-filter="src">
				<option value="">请选择学校</option>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label for="ruxuenian" class="layui-form-label">
			<span class="x-red">*</span>年级
		</label>
		<div class="layui-input-block">
			<select name="ruxuenian" id="ruxuenian" lay-verify="required" class="layui-form-label" lay-filter="src">
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label for="banji_id" class="layui-form-label">
			<span class="x-red">*</span>班级
		</label>
		<div class="layui-input-block" id="banji_id">
		</div>
	</div>
	<div class="layui-form-item">
		<label for="subject_id" class="layui-form-label">
			<span class="x-red">*</span>学科
		</label>
		<div class="layui-input-block" id="subject_id">
		</div>
	</div>
	<div class="layui-form-item" style="text-align: right;">
		<a href="javascript:;" id="preSet" class="layui-btn layui-btn-danger" style="margin-left: 10px;">上一步</a>
		<button class="layui-btn" lay-filter="kssubmit" lay-submit="">
			{$list.set.butname}
		</button>
		<a href="javascript:;" id="nextSet" class="layui-btn layui-btn-danger" style="margin-left: 10px;">完成</a>
	</div>
</form>
{/block}
{block name="myjs"}
<script>
layui.use(['createInput', 'canyuKaoshi', 'form'], function() {
	var cInput = layui.createInput,
		canyu = layui.canyuKaoshi,
		form = layui.form;

	// 搜索教师
	xmselect = cInput.searchTeacher('admin_id');
	canyu.schoolSelect('school_id', "{$list.set.kaoshi_id}");
	canyu.gradeSelect('ruxuenian', "{$list.set.kaoshi_id}");

	// 监听学校下拉菜单
	form.on('select(src)', function(data) {
		data = form.val("myform");
		if (data.school_id > 0 && data.ruxuenian > 0) {
			canyu.banjiCheckbox('banji_id', data);
		}
		canyu.subjectCheckbox('subject_id', data);
	});

	form.on('checkbox(mycheackbox)', function(data) {
		cInput.checkboxChecked(data);
	});

	//监听提交
	form.on('submit(kssubmit)', function(data) {
		$.ajax({
			url: "{$list.set.url}",
			type: "{$list.set.formpost}",
			data: data.field,
			dataType: 'json',
			success: function(result) {
				if (result.val == 1) {
					// $(location).attr('href', '/kaoshi/kaoshiset/create/' + "{$list['set']['kaoshi_id']}");
					window.location.reload();
					parent.layer.msg(result.msg);
				} else {
					layer.msg(result.msg);
				}
			},
			error: function(xhr, status, error) {
				layer.msg('数据处理错误', {
					icon: 2,
					time: 2000 //2秒关闭（如果不配置，默认是3秒）
				});
			}
		});
		return false;
	});


	$('#preSet').click(function() {
		$(location).attr('href', '/kaoshi/index/setp3/' + "{$list['set']['kaoshi_id']}");
		return false;
	})

	$('#nextSet').click(function() {
		//先得到当前iframe层的索引
		var index = parent.layer.getFrameIndex(window.name);
		//再执行关闭
		if (parent.layui.table) {
			parent.layui.table.reload('mytable');
		}
		parent.layer.close(index);
		parent.layer.msg('考试创建完成');
		return false;
	})


});

</script>
{/block}
